import math
'''
class Solution:
    def uniquePaths(self, m: int, n: int) -> int:
        print(math.factorial(m+n-2),math.factorial(m-1),math.factorial(n-1))
        return int(math.factorial(m+n-2)/math.factorial(m-1)/math.factorial(n-1))'''

class Solution:
    def uniquePaths(self, m: int, n: int) -> int:
        cur = [1] * n
        for i in range(1, m):
            for j in range(1, n):
                cur[j] += cur[j-1]
                print(i,j,cur[j])
        return cur[-1]



a=Solution()
print(a.uniquePaths(7,5))